package scopeFunctions

/**
 *@author YanYu
 *@date 2024/12/13 14:19
 */
/**
 * run函数, 与let函数的区别在于,
 * run函数中调用方法不需要通过 it 来调用,
 * 而是直接调用方法名
 */
fun main() {
    fun getNullableLength(ns: String?) {
        println("for \"$ns\":")
        ns?.run {
            println("\tis empty? " + ns.isEmpty())
            println("\tlength = $length")
            length
        }
    }

    getNullableLength(null)
    getNullableLength("")
    getNullableLength("some string with kotlin")
}
